<div>
    <div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor">
        <div class="kt-subheader kt-grid__item">
            <div [class]="containerClass">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title">
                    <i class="icon-fanhui text-info" (click)="backToDeviceEdit()"></i>
                    <span>{{l("DeviceProductSkus")}}</span>
                </h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc">
                    {{deviceId+':'+deviceName +' | '+ productId+':'+productName}}
                </span>
            </div>
            <div class="kt-subheader__toolbar">
                <div class="kt-subheader__wrapper">

                </div>
            </div>
        </div>
        </div>
        <div [class]="containerClass + ' kt-grid__item kt-grid__item--fluid'">
            <div class="kt-portlet kt-portlet--mobile">
                <form #deviceInfooperationForm="ngForm" novalidate autocomplete="off">
                    <div class="kt-portlet__body">
                        <div class="row align-items-center">
                            <form class="horizontal-form" autocomplete="off" name="devicesForm">
                                <div class="kt-form kt-form--label-align-right">
                                    <div class="row align-items-center m--margin-bottom-10">
                                        <div class="col-4">
                                            <div class="form-group kt-form__group align-items-center">
                                                <div class="input-group">
                                                    <input [(ngModel)]="filterText" name="filterText"
                                                        (keyup.enter)="getDeviceProductSkus()" autoFocus
                                                        class="form-control kt-input" [placeholder]="l('name')"
                                                        type="text">
                                                    <span class="input-group-btn">
                                                        <button (click)="getDeviceProductSkus()" class="btn btn-primary"
                                                            type="submit">
                                                            <i class="icon-sousuo-sousuo"></i>
                                                        </button>
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-8" style="text-align: right;">
                                            <div class="form-group">
                                                <button *ngIf="isGranted('Pages.Tenant.Products.Publish')" type="button"
                                                    class="btn btn-primary icon-add"
                                                    (click)="getUnpublishedSkus()">{{l('add')}}</button>
                                                <button *ngIf="isGranted('Pages.Tenant.Products.Publish')" type="button"
                                                    class="btn btn-primary icon-icon-test"
                                                    (click)="withdrawSkusFromDevice()">{{l('deleteBatch')}}</button>
                                                <div class="btn-group btn-group-toggle" data-toggle="buttons">
                                                    <label class="btn btn-secondary active  icon-liebiao"
                                                        (click)="toggleSkuGrid(true)">
                                                        <input type="radio" name="options" id="option1"
                                                            autocomplete="off" checked>
                                                    </label>
                                                    <label class="btn btn-secondary icon-weibiaoti2010102-copy"
                                                        (click)="toggleSkuGrid(false)">
                                                        <input type="radio" name="options" id="option2"
                                                            autocomplete="off">
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                            <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                                <app-image-grid id="GridShow" style="width: 100%;display: none;" mode="1"
                                    judgeOnline="false" gridOwner="sku" (onOperate)="onOperateProductSkus($event)"
                                    lazy="true" [(selection)]="deviceProductSkuSelection"
                                    [imageList]="primengTableHelper.records"></app-image-grid>
                                <p-table #dataTable id="TableShow" (onLazyLoad)="getDeviceProductSkus($event)"
                                    [value]="primengTableHelper.records"
                                    [rows]="primengTableHelper.defaultRecordsCountPerPage" [paginator]="false"
                                    [lazy]="true" [(selection)]="deviceProductSkuSelection"
                                    [resizableColumns]="primengTableHelper.resizableColumns"
                                    [responsive]="primengTableHelper.isResponsive">
                                    <ng-template pTemplate="header">
                                        <tr>
                                            <th>{{l('Actions')}}</th>
                                            <th style="width:5.0em">
                                                <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
                                            </th>
                                            <th style="width:5%">{{l('ID')}}</th>
                                            <th style="width:20%">{{l('name')}}</th>
                                            <th pSortableColumn="creationTime">
                                                {{l('createTime')}}
                                                <p-sortIcon field="creationTime"></p-sortIcon>
                                            </th>
                                            <th pSortableColumn="lastModificationTime">
                                                {{l('updateTime')}}
                                                <p-sortIcon field="lastModificationTime"></p-sortIcon>
                                            </th>
                                            <th>{{l('stock')}}</th>
                                            <th>{{l('salesVolume')}}</th>
                                            <th>{{l('price')}}</th>
                                            <th>{{l('auditStatus')}}</th>
                                            <th>{{l('isDefault')}}</th>
                                        </tr>
                                    </ng-template>
                                    <ng-template pTemplate="body" let-record let-i="rowIndex">
                                        <tr [pSelectableRow]="record">
                                            <td>
                                                <div class="btn-group dropdown" dropdown normalizePosition>
                                                    <button class="dropdown-toggle btn btn-sm btn-primary"
                                                        data-toggle="dropdown" dropdownToggle aria-haspopup="true"
                                                        aria-expanded="false">
                                                        <i class="fa fa-cog"></i>
                                                        <span class="caret"></span> {{l("Actions")}}
                                                    </button>
                                                    <ul class="dropdown-menu" *dropdownMenu>
                                                        <li *ngIf="!record.isDefault">
                                                            <a (click)="setDefault(record)"
                                                                class="icon-bianji dropdown-item">{{l('SaveAsSystemDefault')}}</a>
                                                        </li>
                                                        <li *ngIf="isGranted('Pages.Tenant.Products.Publish')">
                                                            <a (click)="withdrawSku(record)"
                                                                class="icon-icon-test dropdown-item">{{l('Delete')}}</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </td>
                                            <td>
                                                <p-tableCheckbox #TableCheckbox [value]="record"></p-tableCheckbox>
                                            </td>
                                            <!-- <td> {{transIndex(i)}}</td> -->
                                            <td>{{record.id}}</td>
                                            <td>
                                                <span>{{record.title}}</span>
                                            </td>
                                            <td>{{record.creationTime | date:'yyyy/MM/dd'}}</td>
                                            <td>{{record.lastModificationTime | date:'yyyy/MM/dd'}}</td>
                                            <td>{{record.quantity}}</td>
                                            <td>{{record.salesVolume}}</td>
                                            <td>{{'￥'+record.price}}</td>
                                            <td>
                                                <span *ngIf="record['auditStatus']==1"
                                                    class="kt-badge  kt-badge--success kt-badge--inline">{{l("OnSale")}}</span>
                                                <span *ngIf="record['auditStatus']==0"
                                                    class="kt-badge  kt-badge--danger kt-badge--inline">{{l("OffSale")}}</span>
                                            </td>
                                            <td>
                                                <span *ngIf="record['isDefault']"
                                                    class="kt-badge  kt-badge--success kt-badge--inline">{{l("true")}}</span>
                                                <span *ngIf="!record['isDefault']"
                                                    class="kt-badge  kt-badge--danger kt-badge--inline">{{l("false")}}</span>
                                            </td>
                                        </tr>
                                    </ng-template>
                                    <ng-template pTemplate="emptymessage" let-records>
                                        <tr *ngIf="primengTableHelper.records">
                                            <td colspan="11">
                                                <img class="emptymessage"
                                                    src="/assets/common/images/placeholder/skuHolder.png" />
                                            </td>
                                        </tr>
                                    </ng-template>
                                </p-table>
                                <div class="primeng-paging-container">
                                    <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                        (onPageChange)="getDeviceProductSkus($event)"
                                        [totalRecords]="primengTableHelper.totalRecordsCount"
                                        [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                                    </p-paginator>
                                    <span class="total-records-count">
                                        {{l('TotalRecordsCount', primengTableHelper.totalRecordsCount)}}
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <SkusSelectionModal #SkusSelectionModal (modalSave)="publishSkusToDevice($event)"></SkusSelectionModal>